

<div class="container">
	<?php
	if(isset($message) && $message){
		echo '<div class="alert alert-success">'.$message.'</div>';
	}
	?>

	<form id="question-form" name="question-form" action="<?=site_url('admin/level/list')?>" method="post">
		<h2>Level List</h2>
		<input type="hidden" name="id"/>
		<div class="row">
			<div class="form-group col-md-6">
				<label>Name</label>
				<input class="form-control" maxlength="10" name="level_name" id="level_name" type="text" value="<?=set_value('level_name')?>">	
			</div>
			<div class="form-group col-md-6">
				<label>Description</label>
				<input class="form-control" maxlength="10" name="description" id="description" type="text" value="<?=set_value('description')?>">	
			</div>
		</div>
		<div class="form-actions">
			<button type="submit" class="btn btn-primary">Search</button>
			<button type="button" class="btn btn-default" onclick="location.href='/index.php/admin/level/add'">Add</button>
		</div>
	</form>

	<div class="module mod-line-top">
		<table class="table table-striped table-hover">
			<thead>
			  	<tr>
				    <th>#</th>
				    <th>Name</th>
				    <th>Description</th>
				    <th>Operation</th>
			  	</tr>
			</thead>
			<tbody>
				<?php $index = $this->uri->segment(3);?>
				<?php foreach ($results as $item): $offset++;?>
				<tr>
				    <td><a href="/index.php/admin/level/edit/<?=$item['id']?>"><?=$offset?></a></td>
				    <td><a href="/index.php/admin/level/edit/<?=$item['id']?>"><?=$item['level_name']?></a></td>
				    <td><a href="/index.php/admin/level/edit/<?=$item['id']?>"><?=$item['description']?></a></td>
				    <td>
				      	<button type="button" class="btn btn-primary timu-delete" id="<?=$item['id']?>">Delete</button>
      				</td>
			  	</tr>
				<?php endforeach ?>
			  	
			</tbody>
		</table>
		
		<?=$this->pagination->create_links();?>
	</div>
</div>

<script>
$(document).ready(function() {
	$(".timu-edit").each(function(){
		var btn = $(this);
	    btn.click(function(){window.open('/index.php/admin/level/detail/' + btn.attr('id'));})
	});
	
	$(".timu-edit").each(function(){
		var btn = $(this);
	    btn.click(function(){
	    	
	    })
	});
});
</script>
